<template>
    <div class="feedback">
        <wxc-minibar title="建议和反馈" >
        </wxc-minibar>
        <div class="feedback-content">
            <textarea class="feedback-detail" cols="30" rows="10" :value="information.content"  @input="onchange" placeholder="我们有什么可以帮您？"></textarea>
        </div>
		<button class="submit" @click="submit"><text style="font-size:32px;color:#ffffff;">确认反馈</text></button>
        
    </div>
</template>

<script>
import WxcMinibar from "@/components/modules/wxc-minibar/index.js";
import { postResponsesToken } from "@/api.js";
import { getBaseUrl } from "@/utils/index.js";
const modal = weex.requireModule('modal')
const navigator = weex.requireModule("navigator");
const storage = weex.requireModule("storage");
export default {
    components: {
        WxcMinibar
    },
    data() {
        return {
            baseURL:'',
            information:{
                platform:'',
                osVersion:'',
                deviceModel:'',
                content:''
            }
        };
    },
    created(){
        this.baseURL = getBaseUrl(weex.config.bundleUrl, true);
    },
    methods: {
        async submit(){
            storage.getItem('token', event=>{
                if(!event.result || event.data == 'undefined') {
                    navigator.push({
                        'url': this.baseURL + 'views/login/login.js',
                        'animated': 'true'
                    })
                }
            })

            if (this.information.content == '') {
                modal.toast({ message: '留言不能为空' }) 
                return false;
            }
           
           let data = await postResponsesToken('account/message/addMessage', this.information)	;
        
            try{
                if( data.code === 0) {
                    modal.toast({ message: '感谢您的反馈，对于有价值的建议平台将给予奖励，请注意平台消息。' });
                    navigator.pop();
		    	} else {
                    modal.toast({
                        message:data.msg
                    })
		    	}           
            }catch(e){

                
            }
             
            	     
        },
     
        onchange (event) {
            this.information.content = event.value;
        }
    },

    mounted() {
        let { platform, deviceModel, osVersion } = weex.config.env

        this.information['platform'] = platform
        this.information['osVersion'] = osVersion
        this.information['deviceModel'] = deviceModel
    }
};
</script>

<style lang="" scoped>
.feedback {
    background-color: #F5F5F5;
    width:750px;
    align-items: center;
}
.feedback-content {
    width:750px;
    height:400px;
    background-color: #ffffff;
    padding-top:24px;
    padding-left:30px;
    padding-bottom:24px;
    padding-right:30px;
}
.feedback-detail {
    font-size: 28px;
}
.submit {
  width: 622px;
  height: 96px;
  background-color: #e70d0d;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  margin-top: 93px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>